package whackEm.ui;

import whackEm.V2.WhackEmPanel;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;

public class PauseScreen {
	
	public float top,leftResume,leftClose,height,width,bottom;
	private WhackEmPanel panel;
	private Bitmap closeButton;
	private Bitmap resumeButton;
	private RectF pauseRect;
	private Paint pauseRectPaint = new Paint();
	
	
	public PauseScreen(Bitmap closeBitmap,Bitmap resumeBitmap,WhackEmPanel panel) {
		this.closeButton = closeBitmap;
		this.resumeButton = resumeBitmap;
		height =  panel.convertYforDrawable(resumeBitmap.getHeight());
		width =  panel.convertXforDrawable(resumeBitmap.getWidth());	
		this.panel = panel;
		setPosition();
		pauseRectPaint.setARGB(200, 51, 51, 51);		
	}
	
	public void setPosition() {		
		top = panel.convertY((400)) - height;
		bottom = top + height;
		leftResume =  panel.convertX((240 - 10)) - width;
		leftClose  = panel.convertX((245+10));
		pauseRect = new RectF( leftResume - panel.convertX(15) , 
				top - panel.convertY(15), leftClose + width + panel.convertX(15),  top+height+ panel.convertY(15));
		
	}
	
	
	public void update() {
		
	} 
	
	public void draw(Canvas canvas) {
		canvas.drawARGB(100,100,100,100);
		canvas.drawRoundRect(pauseRect, 15, 15, pauseRectPaint);
		canvas.drawBitmap(resumeButton, leftResume, top, null);
		canvas.drawBitmap(closeButton, leftClose, top, null);
		
	} 
	
	public void handleActionDown(float x,float y) {
		if (y >= top && y<= bottom)
			if (x>= leftResume && x<=leftClose)
     			panel.unpauseGame();
			else if (x>=leftClose && x <= leftClose + width)
				panel.stopPlayingAndKillActivity();
				
		
	} 
	
}
